#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START automake

reset_mtime automake automake/configure.ac
rm -rf build/automake
mkdir -p build/automake
cd build/automake

# XXX: avoid dependency on autoconf
# Depending on autoconf being installed on host is fragile.
# Adding $TARGET to the PATH breaks the build.

cat > config.cache <<-EOF
ac_cv_path_EGREP='/bin/grep -E'
ac_cv_path_FGREP='/bin/grep -F'
ac_cv_path_GREP=/bin/grep
ac_cv_path_PERL=/usr/bin/perl
ac_cv_path_install='/bin/install -c'
ac_cv_path_mkdir=/bin/mkdir
ac_cv_prog_AWK=gawk
ac_cv_prog_LEX=flex
ac_cv_prog_TEX=tex
ac_cv_prog_YACC=yacc
am_cv_autoconf_installed=yes
am_cv_autoconf_version=yes
am_cv_autoconf_works=yes
am_cv_make_support_nested_variables=yes
am_cv_prog_cc_c_o=yes
EOF

../../automake/configure \
	${CONFIGURE_ARGS} \
	--cache-file=config.cache \
	${NIL}

# does not really build anything, no point in make -j60
make -j2 V=1
make -j2 install DESTDIR="`pwd`/inst"
shared_dir=`find inst${prefix}/share -type d -name 'automake-*' -printf "%f"`
if [ -z "$shared_dir" ]; then
	echo "failed to find ${prefix}/share/automake-X.Y directory" >&2
	exit 1
fi
ln -sf "$shared_dir" inst${prefix}/share/automake
cd inst
find . | cpio -pumd "$stage"

cd ../../..
rm -rf build/automake

# RECIPE END automake
